import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:test_flutter/constant/resources.dart';
import 'package:test_flutter/model/scoped_model/main_model.dart';
import 'package:test_flutter/pages/HistoryPage.dart';
import 'package:test_flutter/pages/MyOrderPage.dart';
import 'package:test_flutter/pages/cardManagerPage.dart';
import 'package:test_flutter/pages/modifyPWPage.dart';
import 'package:test_flutter/utils/common_utils/CustomLocalizations.dart';
import 'package:test_flutter/utils/factory/Fit.dart';
import 'package:test_flutter/widgets/LineItem.dart';

class PersonalPage extends StatefulWidget {
  final String title;
  PersonalPage(this.title);

  @override
  PersonalCenterState createState() => new PersonalCenterState();
}

class PersonalCenterState extends State<PersonalPage> {
  @override
  Widget build(BuildContext context) {
    return  ScopedModelDescendant<MainModel>(
        builder: (context,child,model){
          return Scaffold(
              backgroundColor: Color(0xFFF6F6F6),
              body: SingleChildScrollView(
                child: Container(
                  child: Column(
                    children: <Widget>[
                      Container(
                        height: Fit.scaleY(680),
                        width: Fit.scaleX(1200),
                        decoration: BoxDecoration(
                            gradient: const LinearGradient(colors: [
                              Color(0xFF3C8CE7),
                              Color(0xFF00EAFF),
                            ], begin: Alignment.topLeft, end: Alignment.bottomRight)),
                        child: Stack(
                          children: <Widget>[
                            new Positioned(
                                left: Fit.scaleX(80 + 200),
                                top: Fit.scaleY(100),
                                child: new CircleAvatar(
                                  backgroundImage:NetworkImage(model.AvatarUrl),
                                  radius: 40.0,
                                )),
                            new Positioned(
                                left: Fit.scaleX(380 + 200),
                                top: Fit.scaleY(150),
                                child: new Column(
                                  crossAxisAlignment:
                                  CrossAxisAlignment.start, // 水平方向左对齐
                                  mainAxisAlignment:
                                  MainAxisAlignment.center, // 竖直方向居中
                                  children: <Widget>[
                                    new Text(
                                      model.Name,
                                      style: new TextStyle(
                                          fontSize: Fit.scaleTextSize(48),
                                          fontWeight: FontWeight.w400,
                                          color: Colors.white),
                                    ),
                                    new Text(
                                      '${model.Area} ${model.Address}',
                                      style: new TextStyle(
                                          fontSize: Fit.scaleTextSize(36), color: Colors.white),
                                    ),
                                  ],
                                )),
                            /*new Positioned(
                                left: Fit.scaleX(700),
                                top: Fit.scaleY(550),
                                child: Text(
                                  '余额：500\$',
                                  style: TextStyle(fontSize: Fit.scaleTextSize(48)),
                                )),*/
                            new Positioned(
                                left: Fit.scaleX(50),
                                top: Fit.scaleY(100),
                                child: GestureDetector(
                                  onTap: () {
                                    Navigator.of(context).pop();
                                  },
                                  child: SizedBox(
                                      width: Fit.scaleX(100),
                                      height: Fit.scaleY(100),
                                      child: Image.asset('images/back.png')),
                                )),
                          ],
                        ),
                      ),
                    /*  LineItem(
                          img: 'images/order.png',
                          title: '我的订单',
                          onTap: () => Navigator.push<Object>(context,
                              new MaterialPageRoute(
                                  builder: (BuildContext context) {
                                    return new MyOrderPage('我的订单');
                                  }))),
                      Divider(
                          color: Colors.black45, height: Fit.scaleY(1)),*/
                      LineItem(
                          img: 'images/card.png',
                          title: CustomLocalizations.instance.getString(StringIds.cardManagement),
                          onTap: () => Navigator.push<Object>(context,
                              new MaterialPageRoute(
                                  builder: (BuildContext context) {
                                    return new CardManagerPage(CustomLocalizations.instance.getString(StringIds.cardManagement));
                                  }))),
                      Divider(
                          color: Colors.black45, height: Fit.scaleY(1)),
                     /* LineItem(
                          img: 'images/history.png',
                          title: CustomLocalizations.instance.getString(StringIds.laundryRecord),
                          onTap: () => Navigator.push<Object>(context,
                              new MaterialPageRoute(
                                  builder: (BuildContext context) {
                                    return new HistoryPage(CustomLocalizations.instance.getString(StringIds.laundryRecord));
                                  }))),
                      Divider(
                          color: Colors.black45, height: Fit.scaleY(1)),*/
                      LineItem(
                          img: 'images/modify.png',
                          title: CustomLocalizations.instance.getString(StringIds.modifyPassWord),
                          onTap: () => Navigator.push<Object>(context,
                              new MaterialPageRoute(
                                  builder: (BuildContext context) {
                                    return new ModufyPWPage();
                                  }))),
                    ],
                  ),
                ),
              ));
        })
    ;
  }
}
